//
//  SetNewPwdVC.m
//  DriverClient
//
//  Created by 吕晶 on 2020/8/4.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "SetNewPwdVC.h"

@interface SetNewPwdVC ()

@property (nonatomic, strong) UITextField *textField;

@end

@implementation SetNewPwdVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HexColor(0xffffff);
    [self configUI];
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 68, 30)];
    [btn setTitle:@"完成" forState:0];
    [btn setTitleColor:HexColor(0xffffff) forState:0];
    btn.backgroundColor = Color_ThemeColor;
    btn.layer.cornerRadius = 15;
    btn.titleLabel.font = BoldFontOfSize(14);
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
}

- (void)btnClick {
    if ([FactoryMethod isNull:self.textField.text]) {
        [MBProgressHUD leShowFailedHUD:self.view message:@"请输入密码"];
        return;
    }
    [HttpRequest PostWithApi:LogisticsSupplierSetNewPwd params:@{@"password":self.textField.text} progress:^(NSProgress * _Nonnull progress) {

    } success:^(NSURLSessionDataTask * _Nonnull operation, id  _Nonnull responseObject, BOOL code, NSInteger errorCode) {
        if (code) {
            [MBProgressHUD leShowSuccessHUDAddedTo:self.view message:@"设置成功,请重新登录" delayOperation:^{
                [User logoutSuccess];
            }];
        }
    } fail:^(NSError * _Nonnull error) {

    }];
}

- (void)configUI {
    UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 30, ScreenW - 30, 21)];
    titleLab.font = BoldFontOfSize(20);
    titleLab.text = @"请设置新密码";
    titleLab.textColor = HexColor(0x2B2C44);
    [self.view addSubview:titleLab];
    
    UILabel *descLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 30 + titleLab.nim_bottom, ScreenW - 30, 15)];
    descLab.font = [UIFont systemFontOfSize:14];
    descLab.text = @"新密码";
    descLab.textColor = HexColor(0x2B2C44);
    [self.view addSubview:descLab];
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(titleLab.nim_left, descLab.nim_bottom + 5, descLab.nim_width, 40)];
    self.textField.placeholder = @"请输入密码";
    self.textField.textColor = HexColor(0x2B2C44);
    self.textField.font = [UIFont systemFontOfSize:16];
    self.textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self.view addSubview:self.textField];
    
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(self.textField.nim_left, self.textField.nim_bottom, self.textField.nim_width, 1)];
    line.backgroundColor = HexColor(0xF2F2F5);
    [self.view addSubview:line];
}

@end
